<script src="<?=base_url(); ?>theme/js/main.js"></script>
<script type="text/javascript">
                                                            
$(document).ready(function(){
$('.table_top').hide(); //Oculta la parte de búsqueda por defecto de la tabla de productos .
});

</script>

<div class="grid_container">
	<div class="grid_12">
		<div class="widget_wrap">
			<div class="widget_top">
				<span class="h_icon clipboard"></span>
				<h6>Reporte de Ventas por Cliente</h6>
			</div>
			<div class="form_container">
				<ul>
					<li>
						<div class="form_grid_12">
					
							<div class="form_input">
							
							<form method="post" action="">
                                                             <ul id="datos">
                         <li>
                            <div class="form_grid_12">
                                <div class="form_input">
                                    <div class="form_grid_5 alpha">
                                        <label class="field_title">Cliente</label>
                                        <?php
                                        $options = array();
                                        $options[0] = "";
                                        foreach ($clients as $td) {
                                            $options[$td->id] = $td->name;
                                        }

                                        $extra = 'id="client" tabindex="3" style="width:340px" class="chzn-select full" data-placeholder="Elegir..."';

                                        $buscando_cliente_de_guia = ''; /* variable que contendra el cliente de la guia buscada */
                                        $buscando_cliente_de_guia = $client;
                                           

                                        echo form_dropdown('client', $options, $buscando_cliente_de_guia, $extra);
                                        ?>
                                         <input type="text" name="ware" value="" id="ware">
                                    </div>
                                                       
                                    <span class="clear"></span>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form_grid_12">
                                <div class="form_input">
                                    <div class="form_grid_2">
                                        <label style="margin-left: -10px;" class="field_title">Desde</label>
                                        <input style="margin-left: -10px;" type="text" name="desde" id="desde" value="<?echo $desde?>" placeholder = "dd/mm/yyyy" required>
                                    </div>
                                    <div class="form_grid_2">
                                        <label style="margin-left: 107px;" class="field_title">Hasta</label>
                                        <input  style="margin-left: 107px;" type="text" name="hasta" id="hasta" value="<?echo $hasta?>" placeholder = "dd/mm/yyyy" required>

                                    </div>
                                    <div class="form_grid_2">
                                    <button style="margin-left: 160px;margin-top: 25px;size: 120px" id="Reporte" class="btn_small btn_blue"><span>  Procesar </span></button>                             
                                    </div>
                                    <span class="clear"></span>
                                </div>
                            </div>
                        </li>
                                                
                    </ul>   
							</form>
							</div>
						</div>
					</li>
				</ul>
			</div>

                    


<div id="view_stock" style="display:none;">
                                

                            </div>
<div class="widget_content">
				<table class="wtbl_list">
					<thead>
						<tr>
							<th>Fecha</th>
							<th>Documento</th>
							<th>Cliente</th>
							<th>Total</th>                                                        							
						</tr>
					</thead>
					<tbody>
					<?php $i = 0;
                                        $total = 0; ?>
					<?php foreach ($shops as $p) : ?>
                                            
					    <?php $i++; ?>
                                            
						<tr class="stockProduct tr_even" id="view_stock_<?= $i; ?>"  codeProduct="" style="cursor: pointer;">
							<td align="center"><?  $datei = $p->date;
                                                                $date = str_replace('-', '/', $datei);
                                                                $datef = date("d/m/Y", strtotime($date) );
                                                                echo $datef; ?></td>
							<td align="center"><?  echo "GV ".$p->document_code; ?></td>
							<td align="center"><?=$p->client; ?></td>   
                                                        <td align="center"><?=$p->amount; ?></td>   							
						</tr>
                                                <?                                                
                                                $total =$total+$p->amount;?>
                                          <?php endforeach; ?>
					</tbody>
				</table>
                    <input type="text" name="total" id="total" placeholder="0.00" value="<?php                           
                               echo $total;                           
                    ?>" readonly="true" style=" text-align:center; width: 100px; margin-right:10px; float: right; background: #D0D0D0; font-family: arial; font-size: 15px; font-weight: bold;">
                            <span class="clear"></span>
			</div>
		</div>
	</div>
    
    
    
	
</div>